package com.lenovo.nova.util.fragment;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lenovo.nova.util.Constant;
import com.lenovo.nova.util.DebugUtil;
import com.lenovo.nova.util.debug.MyOldLog;
import com.lenovo.nova.util.debug.mylog;

public class BaseFragment extends Fragment implements Constant {

	/**
	 * 尝试为每个子Fragmentg的View做个缓存
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mylog.i(Debug.METHOD_TAG, getName() + " onCreate ");
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		mylog.i(Debug.METHOD_TAG, getName() +" onDestroy");
	}

	@Override
	public void onDestroyView() {
		super.onDestroyView();
		mylog.i(Debug.METHOD_TAG, getName() +" onDestroyView");
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		mylog.i(Debug.METHOD_TAG,getName() +" onActivityCreated ");
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		RuntimeException e = new RuntimeException("child need overwirte this method");
		throw e;
	}
	
	@Override
	public void onStart() {
		super.onStart();
		mylog.i(Debug.METHOD_TAG,getName() + " onStart");
	}

	@Override
	public void onStop() {
		super.onStop();
		mylog.i(Debug.METHOD_TAG, getName() +" onStop");
	}

	@Override
	public void onResume() {
		super.onResume();
		mylog.i(Debug.METHOD_TAG,getName() + " onResume");
	}

	@Override
	public void onPause() {
		super.onPause();
		mylog.i(Debug.METHOD_TAG, getName() +" onPause");
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		MyOldLog.p(Debug.METHOD_TAG, getName() + "onAttach");
	}
	
	@Override
	public void onDetach() {
		super.onDetach();
		MyOldLog.p(Debug.METHOD_TAG, getName() + "onDetach");
	}
	
	@Override
	public void onSaveInstanceState(Bundle outState) {
		// TODO (liuzd2) 以后可以做个统计，看看调用了多次该方法
		super.onSaveInstanceState(outState);
		mylog.i(Debug.METHOD_TAG, getName() +" onSaveInstanceState");
	}

	@Override
	public void onDestroyOptionsMenu() {
		super.onDestroyOptionsMenu();
		mylog.i(Debug.METHOD_TAG, getName() +" onDestroyOptionsMenu");
	}

    public void onDumpExecute(DebugUtil util,String cmdValue){

    }

//	protected void printLog(String methodTag, String string) {
//		Log.i(methodTag, string);
//	}

	protected void printLog(String str) {
		Log.i("NovaSpeech", getName() + "\t" + str);
	}

	public String getName() {
		return this.getClass().getSimpleName()+"(" +hashCode()+")" + "\t";
	}

} 